package com.dyp.global_exception_handler.ctr;

import java.beans.PropertyEditorSupport;

public class NameEditor extends PropertyEditorSupport {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (text == null || text.isEmpty())  {
            setValue(null);
        } else {
            // 将首字母大写，其余小写
            String formatted = text.substring(0,  1).toUpperCase() +
                    text.substring(1).toLowerCase();
            setValue(formatted);
        }
    }
}